import request from "@/utils/request";

const LOG_BASE_URL = "/v3/manager/deviceType";

class DeviceTypeApi {
  /**
   * 添加设备类型
   *
   * @param queryParams 查询参数
   */
  static addDevType(queryParams: DeviceTypeReq) {
    return request({
      url: `${LOG_BASE_URL}/save`,
      method: "post",
      headers: {
        "Content-Type": "application/json",
      },
      data: queryParams,
    });
  }

  /**
   * 获取设备类型分页列表
   *
   * @param queryParams 查询参数
   */
  static getFences(queryParams: FencesPageQuery) {
    return request<any, LogPageVO>({
      url: `${LOG_BASE_URL}/page`,
      method: "post",
      headers: {
        "Content-Type": "application/json",
      },
      data: queryParams,
    });
  }

  /**
   * 编辑设备类型
   *
   * @param queryParams 查询参数
   */
  static editSave(queryParams: DeviceTypeReq) {
    return request({
      url: `${LOG_BASE_URL}/update`,
      method: "put",
      headers: {
        "Content-Type": "application/json",
      },
      data: queryParams,
    });
  }
  /**
   * 删除设备类型
   *
   * @param queryParams 查询参数
   */
  static deleteSave(queryParams: number) {
    return request({
      url: `${LOG_BASE_URL}/delete/${queryParams}`,
      method: "delete",
      headers: {
        "Content-Type": "application/x-www-form-urlencoded",
      },
    });
  }
  static deviceTypeOptions() {
    return request<any, typeOptions[]>({
      url: `${LOG_BASE_URL}/options`,
      method: "get",
    });
  }
}

export default DeviceTypeApi;

/**
 * 日志分页查询对象
 */
export interface LogPageQuery {
  /** 搜索关键字 */
  keywords?: string;
  pages?: any;
  module?: string;
  operation?: string;
  content?: string;
  type?: string;
  ip?: string;
  customerId?: number;
}

/**
 * 系统日志分页VO
 */
export interface LogPageVO {
  current: number;
  pages: number;
  records: Array<any>;
  size: number;
  total: number;
}

/**
 * 设备类型分页
 */
export interface FencesPageQuery {
  /** 搜索关键字 */
  pages?: any;
  typeName?: string;
  customerId?: number;
  fenceName?: string;
}
/**
 * 设备类型分页
 */
export interface deviceTypePageQueryList {
  /** 搜索关键字 */
  pages?: any;
  typeName?: string;
  customerId?: number;
}

export interface addFencesPageQuery {
  /** 搜索关键字 */
  id?: string;
  fenceName: string;
  customerId: string;
  coordinateSet: Array<any>;
}

/**
 * 设备类型
 */
export interface DeviceTypeReq {
  id?: string;
  typeName: string;
  remark: string;
  typeCode: string;
}
export interface typeOptions {
  label: string;
  value: string;
}
